<?php
//处理跨域
namespace app\api\controller;

use think\Controller;

class Base extends Controller {
    protected function initialize(){
        parent::initialize();
        // 设置跨域访问
        header('Access-Control-Allow-Origin: *');
        header("Access-Control-Allow-Headers:Authorization,Origin, X-Requested-With, Content-Type, Accept,If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since ");
        header('Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS,PATCH');
        if(request()->isOptions()){
            exit();
        }
    }
}

?>